package cn.edu.gdgm.system.config;

/**
 * @author quan
 * date 2021-01-14
 */

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;


@Component
public class WxMaConfiguration {
    @Autowired
    private WeChatAccountConfig weChatAccountConfig;

    @Bean
    public WxMaService wxMpService() {
        WxMaService wxMaService = new WxMaServiceImpl();
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(weChatAccountConfig.getAppid());
        config.setSecret(weChatAccountConfig.getAppSecret());
        wxMaService.setWxMaConfig(config);
        return wxMaService;
    }
}